package com.sendingFBpost;

import android.app.AlertDialog;
import android.app.ProgressDialog;
import android.os.AsyncTask;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

//
//import com.fbexample.Facebook;
public class MyAsyncTask 
	extends AsyncTask<Void, Void, Void>
    {
	//private Facebook facebook;
       // ProgressDialog mProgressDialog;
        @Override
        protected void onPostExecute(Void result) {
            //mProgressDialog.dismiss();
        }

        @Override
        protected void onPreExecute() {
          //  mProgressDialog = ProgressDialog.show(ActivityName.this, "Loading...", "Data is Loading...");
        	//Facebook fb=new Facebook(); 
        	FBAppActivity fb=new FBAppActivity();   
        	Bundle parameters = new Bundle();
        	  parameters.putString("message", "testing123yaar");
        	  parameters.putString("description", "topic share");
        	  try {    
        		  fb.facebook.request("me");
        	   String response = fb.facebook.request("me/feed", parameters, "POST");
        	   Log.d("Tests", "got response: " + response);
        	   if (response == null || response.equals("") || response.equals("false")) {
        	    showToast("Blank response.");  
        	   } else { 
        	    showToast("Message posted to your facebook wall!");
        	   }
        	  // finish();
        	  } catch (Exception e) {
        	   showToast("Failed to post to wall!");
        	   e.printStackTrace();
        	   //finish();   
        	  }
        }

        @Override 
        protected Void doInBackground(Void... params) {
           // your network operation
            return null;
        }        private void showToast(String message) {
       	 // Toast.makeText(MyAsyncTask.this, message, Toast.LENGTH_SHORT).show();
        	//AlertDialog.Builder al=new AlertDialog.Builder(MyAsync);
      	 }
    
}
